package eu.kuresson.tower.service;

import javax.persistence.EntityManager;
import javax.persistence.PersistenceContext;

import org.springframework.security.crypto.encrypt.Encryptors;
import org.springframework.security.crypto.encrypt.TextEncryptor;
import org.springframework.security.crypto.keygen.KeyGenerators;

import eu.kuresson.tower.model.SecUser;

public class GamePlayService {
	private TextEncryptor textEncryptor = Encryptors.text("password", KeyGenerators.string().generateKey());
	private EntityManager entityManager;

    public void setEntityManager(EntityManager newEm){
        this.entityManager = newEm;
    }
    
	public void insertUser() {
		System.out.println("Insert");
		SecUser user = new SecUser("test", textEncryptor.encrypt("test"));

		entityManager.persist(user);
	}
	
	public String getEncryptedPass(String password) {
		return textEncryptor.encrypt(password);
	}
}
